{template '_header'}
<div class="page-heading" style="margin-bottom:0">
    <span class="pull-right">
        <a class="btn btn-default btn-sm" href="{php echo webUrl('exchange/goods')}">返回列表</a>
        </span>
    <h2>{if $id>0}编辑商品兑换任务{else}添加商品兑换任务{/if}</h2>
</div>
<form
        {if $id>0}action="{php echo webUrl('exchange/group/edit',array('id'=>$id),true);}"
    {else}action="{php echo webUrl('exchange/group/add',array(),true);}"
    {/if} method="post" class="form-horizontal form-validate" novalidate="novalidate" id="setform">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog"  style="width: 850px">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                        请选择商品
                    </h4>
                </div>
                <div class="modal-body">
                    <div id="goods">
                        <!--搜索条-->
                        <div class="modal-body" style="width: 80%;margin-left: 10%;">
                            <div class="row">
                                <div class="input-group">
                                    <input type="text" class="form-control" name="keyword" id="keyword"
                                           placeholder="请输入关键词">
                                    <span class="input-group-btn">
                                  <button type="button" class="btn btn-default" id="so">搜索</button>
                            </span>
                                </div>
                            </div>
                        </div>

                        <div id="myTabContent" class="tab-content">
                            <div class="tab-pane fade in active" id="no">
                                <div style="max-height:500px;overflow:auto;min-width:500px;">
                                    <table class="table tableso">

                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-primary" data-dismiss="modal">
                        选好了
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
        <div class="form-group" style="padding: 30px 10px 0">
            {if !empty($id)}
            <ul id="myTab" class="nav nav-tabs">
                <li class="active"><a href="#home" data-toggle="tab">{if $id>0}编辑商品兑换{else}添加商品兑换{/if}</a></li>
                <li><a href="#message" data-toggle="tab">消息通知</a></li>
                <li><a href="#zhuangxiu" data-toggle="tab">页面设置</a></li>
            </ul>
            {/if}
            <div id="myTabContent" class="tab-content">
                <div class="tab-pane fade in active" id="home">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">兑换任务标题</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" placeholder="请输入标题" class="form-control" name="title" value="{$setting['title']}" required>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">兑换开始时间</label>
                        <div class="col-sm-9 col-xs-12">
                            {php echo tpl_form_field_date('starttime',$setting['starttime'],true);}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">兑换截止时间</label>
                        <div class="col-sm-9 col-xs-12">
                            {php echo tpl_form_field_date('endtime',$setting['endtime'],true);}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">兑换券类型</label>
                        <div class="col-sm-9 col-xs-12">
                            <label for="code0" class="radio-inline"><input type="radio" name="code_type" class="code_type" value="0" id="code0" {if empty($setting['code_type'])}checked{/if} {if !empty($id)}disabled="disabled"{/if}> 微信临时二维码</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label for="code1" class="radio-inline"><input type="radio" name="code_type" class="code_type" value="1" id="code1" {if $setting['code_type']==1}checked{/if} {if !empty($id)}disabled="disabled"{/if}> 微信永久二维码</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label for="code2" class="radio-inline"><input type="radio" name="code_type" class="code_type" value="2" id="code2" {if $setting['code_type']==2}checked{/if} {if !empty($id)}disabled="disabled"{/if}> 普通链接二维码</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label for="code3" class="radio-inline"><input type="radio" name="code_type" class="code_type" value="3" id="code3" {if $setting['code_type']==3}checked{/if} {if !empty($id)}disabled="disabled"{/if}> 纯数字兑换码</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">用户扫码绑定</label>
                        <div class="col-sm-9  col-xs-12">
                            <label for="binding" class="radio-inline"><input type="checkbox" name="binding" id="binding" {if $setting['binding'] == 1}checked{/if}> 开启扫码绑定</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label">选择兑换项目</label>
                        <div class="col-sm-9 col-xs-12">
                            <label for="select_goods" class="radio-inline"><input type="checkbox" name="select[]" class="type" value="1" id="select_goods" {if $setting['type']!=0}checked{/if}> 商品兑换</label>
                            <label for="select_balance" class="radio-inline"><input type="checkbox" name="select[]" class="type" value="2" id="select_balance" {if $setting['balance_type']!=0}checked{/if}> 余额兑换</label>
                            <label for="select_red" class="radio-inline"><input type="checkbox" name="select[]" class="type" value="3" id="select_red" {if $setting['red_type']!=0}checked{/if}> 红包兑换</label>
                            <label for="select_score" class="radio-inline"><input type="checkbox" name="select[]" class="type" value="4" id="select_score" {if $setting['score_type']!=0}checked{/if}> 积分兑换</label>
                            <label for="select_coupon" class="radio-inline"><input type="checkbox" name="select[]" class="type" value="5" id="select_coupon" {if $setting['coupon_type']!=0}checked{/if}> 优惠券兑换</label>
                        </div>
                    </div>

                    <div class="well" id="goods-group" style="width: 90%;margin-left: 5%;{if $setting['type']==0}display: none;{/if}">
                        <h3 style="margin-left: 15px">商品兑换</h3>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">选择兑换模式</label>
                        <div class="col-sm-9 col-xs-12">
                            <label for="bdadd" class="radio-inline"><input type="radio" name="type" class="type" value="1" id="bdadd" onclick="$('#max').show();$('#mianzhiadd').hide();" {if $setting['type']!=2}checked{/if}> 按商品兑换</label>&nbsp;&nbsp;&nbsp;&nbsp;
                            <label for="adadd" class="radio-inline"><input type="radio" name="type" class="type" value="2" id="adadd" onclick="$('#mianzhiadd').show();$('#max').hide()" {if $setting['type']==2}checked{/if}> 按面值兑换</label>
                        </div>
                    </div>

                    <div class="form-group" id="shangpinadd">
                        <label class="col-sm-2 control-label">选择指定商品</label>
                        <div class="col-sm-9 col-xs-12">
                            <a data-toggle="modal" data-target="#myModal"
                               class="form-control">点击选择商品</a>
                        </div>
                    </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">已选商品</label>
                            <div class="col-sm-9 col-xs-12">
                                <div class="input-group multi-audio-details container">
                                    <table class="table" style="width:600px;">
                                        <thead>
                                        <tr>
                                            <th style="width:80px;">商品名称</th>
                                            <th style="width:220px;"></th>
                                            <th>规格/库存/运费</th>
                                            <th style="width:50px;">操作</th>
                                        </tr>
                                        </thead>
                                        <tbody id="param-items" class="ui-sortable tablet">
                                        {loop $all $k $v}
                                        <tr class="multi-product-item" data-id="{$v[0]['id']}" data-name="goodsid">
                                            <input type="hidden" name="no_checkbox[]" value="{$v[0]['id']}" data="{$v[0]['id']}">
                                            <td style="width:80px;"><img src="{php echo tomedia($v[0]['thumb']);}" height="70px"></td><td style="width:220px;">{$v[0]['title']}</td><td><a class="btn btn-default btn-sm" data-toggle="ajaxModal" href="{php echo webUrl('exchange/goods/optionset',array('gtype'=>0,'groupid'=>$id,'id'=>$v[0]['id']));}">设置</a></td><td><a href="javascript:void(0);" class="btn btn-default btn-sm" title="删除" data-id="{$v[0]['id']}" onclick="biz.selector_new.remove(this,'goodsid')"><i class="fa fa-times"></i></a></td></tr>
                                        {/loop}
                                        {loop $hasoption $k $v}
                                        <tr class="multi-product-item" data-id="{$v[0]['id']}" data-name="goodsid">
                                            {loop $goods['option'][$v[0]['id']] $k2 $v2}
                                            <input type="hidden" name="has_checkbox[]" value="{$v[0]['id']}_{$v2}" data="{$v[0]['id']}">
                                            {/loop}
                                            <td style="width:80px;"><img src="{php echo tomedia($v[0]['thumb']);}" height="70px"></td><td style="width:220px;">{$v[0]['title']}</td><td><a class="btn btn-default btn-sm" data-toggle="ajaxModal" href="{php echo webUrl('exchange/goods/optionset',array('gtype'=>1,'groupid'=>$id,'id'=>$v[0]['id']));}&selected={php echo implode('_',$goods['option'][$v[0]['id']]);}">设置</a></td><td><a href="javascript:void(0);" class="btn btn-default btn-sm" title="删除" data-id="{$v['id']}" onclick="biz.selector_new.remove(this,'goodsid')"><i class="fa fa-times"></i></a></td></tr>
                                        {/loop}
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    <div class="form-group" id="mianzhiadd" {if $setting['type']!=2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">输入指定面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="input" class="form-control" name="value" value="{$setting['value']}">
                    </div>
                        </div>
                    <div class="form-group" id="max" {if $setting['type']==2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">最大兑换件数</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="max" class="form-control" {if $id>0}value="{$setting['max']}"{else}value="1"{/if}>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">订单运费设置</label>
                        <div class="col-sm-9 col-xs-12">
                            <label for="dan" class="radio-inline"><input type="radio" name="postagetype" id="dan" {if empty($setting['postage_type'])}checked{/if} onclick="$('.postage').show();" value="0">按单计算</label>&nbsp;&nbsp;&nbsp;
                            <label for="jian" class="radio-inline"><input type="radio" name="postagetype" id="jian" {if $setting['postage_type'] == 1}checked{/if} onclick="$('.postage').hide();" value="1">按件计算</label>
                        </div>
                    </div>
                    <div class="form-group postage" {if $setting['postage_type'] == 1}style="display: none"{/if}>
                        <label class="col-sm-2 control-label">输入每单运费</label>
                        <div class="col-sm-9 col-xs-12">
                            <input type="text" name="postage" class="form-control" value="{$setting['postage']}">
                        </div>
                </div>
            </div>
        </div>



            <div class="well" id="balance-group" style="width: 90%;margin-left: 5%;{if $setting['balance_type']==0}display: none;{/if}">
                <h3 style="margin-left: 15px">余额兑换</h3>
                <div class="form-group">
                    <label class="col-sm-2 control-label">余额兑换模式</label>
                    <div class="col-sm-9 col-xs-12">
                        <label for="balance1" class="radio-inline"><input type="radio" name="balancetype" class="type" value="1" id="balance1" onclick="$('#balance_rand').hide();$('#balance').show();" {if $setting['balance_type']!=2}checked{/if}> 指定余额兑换</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        <label for="balance2" class="radio-inline"><input type="radio" name="balancetype" class="type" value="2" id="balance2" onclick="$('#balance_rand').show();$('#balance').hide();" {if $setting['balance_type']==2}checked{/if}> 随机余额兑换</label>
                    </div>
                </div>
                <div class="form-group" id="balance" {if $setting['balance_type']==2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">余额面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="input" class="form-control" name="balance" value="{$setting['balance']}">
                    </div>
                </div>
                <div class="form-group" id="balance_rand" {if $setting['balance_type']!=2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">余额面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
                            <input type="text" name="balance_left" class="form-control"
                                   value="{$setting['balance_left']}">
                            <span class="input-group-addon">元</span><span class="input-group-addon">至</span>
                            <input type="text" name="balance_right" class="form-control"
                                   value="{$setting['balance_right']}">
                            <span class="input-group-addon">元</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="well" id="red-group" style="width: 90%;margin-left: 5%;{if $setting['red_type']==0}display: none;{/if}">
                <h3 style="margin-left: 15px">红包兑换</h3>
                <div class="form-group">
                    <label class="col-sm-2 control-label">红包兑换模式</label>
                    <div class="col-sm-9 col-xs-12">
                        <label for="red1" class="radio-inline"><input type="radio" name="redtype" class="type" value="1" id="red1" onclick="$('#red_rand').hide();$('#red').show();" {if $setting['red_type']!=2}checked{/if}> 指定红包兑换</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        <label for="red2" class="radio-inline"><input type="radio" name="redtype" class="type" value="2" id="red2" onclick="$('#red_rand').show();$('#red').hide();" {if $setting['red_type']==2}checked{/if}> 随机红包兑换</label>
                    </div>
                </div>
                <div class="form-group" id="red" {if $setting['score_type']==2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">红包面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="input" class="form-control" name="red" value="{$setting['red']}">
                    </div>
                </div>
                <div class="form-group" id="red_rand" {if $setting['score_type']!=2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">红包面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
                            <input type="text" name="red_left" class="form-control"
                                   value="{$setting['red_left']}">
                            <span class="input-group-addon">元</span><span class="input-group-addon">至</span>
                            <input type="text" name="red_right" class="form-control"
                                   value="{$setting['red_right']}">
                            <span class="input-group-addon">元</span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="well" id="score-group" style="width: 90%;margin-left: 5%;{if $setting['score_type']==0}display: none;{/if}">
                <h3 style="margin-left: 15px">积分兑换</h3>
                <div class="form-group">
                    <label class="col-sm-2 control-label">积分兑换模式</label>
                    <div class="col-sm-9 col-xs-12">
                        <label for="score1" class="radio-inline"><input type="radio" name="scoretype" class="type" value="1" id="score1" onclick="$('#score_rand').hide();$('#score').show();" {if $setting['score_type']!=2}checked{/if}> 指定积分兑换</label>&nbsp;&nbsp;&nbsp;&nbsp;
                        <label for="score2" class="radio-inline"><input type="radio" name="scoretype" class="type" value="2" id="score2" onclick="$('#score_rand').show();$('#score').hide();" {if $setting['score_type']==2}checked{/if}> 随机积分兑换</label>
                    </div>
                </div>
                <div class="form-group" id="score" {if $setting['score_type']==2}style="display: none"{/if}>
                    <label class="col-sm-2 control-label">积分面值</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="input" class="form-control" name="score" value="{$setting['score']}">
                    </div>
                </div>
                <div class="form-group" id="score_rand" {if $setting['score_type']!=2}style="display: none"{/if}>
                <label class="col-sm-2 control-label">积分面值</label>
                <div class="col-sm-9 col-xs-12">
                    <div class="input-group">
                        <input type="text" name="score_left" class="form-control"
                               value="{$setting['score_left']}">
                        <span class="input-group-addon">元</span><span class="input-group-addon">至</span>
                        <input type="text" name="score_right" class="form-control"
                               value="{$setting['score_right']}">
                        <span class="input-group-addon">元</span>
                    </div>
                </div>
            </div>
            </div>
            <div class="modal fade" id="couponModal" tabindex="-1" role="dialog" aria-labelledby="couponModalLabel" aria-hidden="true">
                <div class="modal-dialog" style="width: 800px">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                                &times;
                            </button>
                            <h4 class="modal-title" id="couponModalLabel">
                                选择优惠券
                            </h4>
                        </div>
                        <div class="modal-body">
                                <h3>请选择优惠券</h3>
                                <!--搜索条-->
                                <div class="modal-body" style="width: 80%;margin-left: 10%;">
                                    <div class="row">
                                        <div class="input-group">
                                            <input type="text" class="form-control" name="keyword" id="goodsid_input"
                                                   placeholder="请输入关键词">
                                            <span class="input-group-btn">
                                            <button type="button" class="btn btn-default"
                                                    onclick="so2()">搜索</button>
                                        </span>
                                        </div>
                                    </div>
                                </div>

                            <script>
                                function so2(){
                                var keyword = $('#goodsid_input').val();
                                $.ajax({
                                    url:"{php echo webUrl('exchange/coupon/couponsearch')}&id={$id}&keyword="+keyword,
                                    success:function (data) {
                                        $('.ui-sortable').html(data);
                                    }
                                });
                            }</script>
                                <div style="max-height:500px;overflow:auto;min-width:500px;">
                                    <table class="table">
                                        <thead>
                                        <tr>
                                            <td style="width: 20%">排序</td>
                                            <td style="width: 30%">优惠券名称</td>
                                            <td style="width:30%">参与兑换量</td>
                                            <td>是否选择</td>
                                        </tr>
                                        </thead>
                                        <tbody class="ui-sortable">
                                        {loop $allcoupon $key $value}
                                        <tr>
                                            <td>1</td>
                                            <td>{$value['couponname']}</td>
                                            <td>
                                                <a href="javascript:;" data-toggle="ajaxEdit"
                                                   data-href="{php echo webUrl('exchange/coupon/stock',array('goodsid'=>$value['id']));}"
                                                   style="display: inline;">{$value['id']}</a>
                                            </td>
                                            <td>
                                                <div class="onoffswitch">
                                                    <input type="checkbox" name="checkbox[]"
                                                           class="onoffswitch-checkbox" id="no{$value['id']}"
                                                           value="{$value['id']}" {if $coupon!=null &&in_array($value['id'],$coupon)}checked{/if}>
                                                    <label class="onoffswitch-label" for="no{$value['id']}">
                                                        <span class="onoffswitch-inner"></span>
                                                        <span class="onoffswitch-switch"></span>
                                                    </label>
                                                </div>
                                            </td>
                                        </tr>
                                        {/loop}
                                        </tbody>
                                    </table>
                                </div>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-primary" data-dismiss="modal">
                                选好了
                            </button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal -->
            </div>
            <div class="well" id="coupon-group" style="width: 90%;margin-left: 5%;{if $setting['coupon_type']==0}display: none;{/if}">
                <h3 style="margin-left: 15px">优惠券兑换</h3>
                <div class="form-group">
                    <label class="col-sm-2 control-label">兑换模式</label>
                    <div class="col-sm-9 col-xs-12">

                        <label for="coupon1" class="radio-inline"><input type="radio" name="coupontype" class="type" value="1" id="coupon1" {if $setting['coupon_type']==1}checked{/if}> 发放全部选定优惠券</label>&nbsp;&nbsp;&nbsp;&nbsp;

                        <label for="coupon2" class="radio-inline"><input type="radio" name="coupontype" class="type" value="2" id="coupon2" {if $setting['coupon_type']!=1}checked{/if}> 随机发放一个优惠券</label>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">选择优惠券</label>
                    <div class="col-sm-9 col-xs-12">
                        <a data-toggle="modal" data-target="#couponModal" class="form-control">点击选择优惠券</a>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-9  col-xs-12">
                    <input type="submit" value="保存" class="btn btn-primary">
                </div>
            </div>

</form>
</div>


<div class="tab-pane fade" id="message">
    <form action="{if $setting['code_type'] != 3}{php echo webUrl('exchange/goods/setting',array('id'=>$id),1);}{else}{php echo webUrl('exchange/goods/addreply',array('id'=>$id),1);}{/if}" method="post" class="form-horizontal form-validate" novalidate="novalidate" id="setform">
        <div class="form-group">
            <label class="col-sm-2 control-label">兑换入口链接</label>
            <div class="col-sm-9 col-xs-12">
                <a>{php echo mobileUrl("exchange",array('codetype'=>1,'id'=>$id),1);}</a>
            </div>
        </div>
        {if $setting['code_type'] != 3}
        <div class="form-group">
            <label class="col-sm-2 control-label">推送消息类型</label>
            <div class="col-sm-9 col-xs-12">
                <label for="on" class="radio-inline"><input type="radio" name="reply" class="type" value="0" id="on" onclick="$('#yulan').show();$('#wenzi').hide();" {if $setting['reply_type'] == 0}checked{/if}> 图文消息</label>&nbsp;&nbsp;&nbsp;&nbsp;
                <label for="off" class="radio-inline"><input type="radio" name="reply" class="type" value="1" id="off" onclick="$('#yulan').hide();$('#wenzi').show();" {if $setting['reply_type'] == 1}checked{/if}> 文字消息</label>
            </div>
        </div>
        {/if}
        <div id="wenzi" {if $setting['reply_type'] == 0}style="display: none;"{/if}>
        <script>
            require(['jquery','util'], function($, util){
                $(function(){
                    $('#btn').click(function(){
                        util.emojiBrowser(function(emoji){
                            var text = '[U+'+emoji[0].text+']';
                            var content = $('#content').val()+text;
                            $('#content').val(content);

                        });
                    });
                });

                $(function(){
                    util.emotion($('#emotion'), $('#content'));
                });

                $(function () {
                    $('#link').click(function () {
                        var link='<a href="[兑换链接]">点击进入兑换中心</a>';
                        var content = $('#content').val()+link;
                        $('#content').val(content);
                    });
                });
            });
        </script>
        <div class="form-group">
            <label class="col-sm-2 control-label">输入文字内容</label>
            <div class="col-sm-9 col-xs-12">
                <textarea style="height: 150px;resize: none;" class="form-control" placeholder='支持<a href=""></a>标签' name="content" id="content">{$setting['basic_content']}</textarea>
                <div class="edit" style="width: 100%;height: 30px;border-bottom:1px solid #e5e6e7;border-left:1px solid #e5e6e7;border-right:1px solid #e5e6e7;">
                    <div style="width: 30px;height: 30px;float: left;margin-left: 20px">
                        <a href="javascript:" id="btn" title="插入emoji">
                            <img src="../addons/ewei_shopv2/plugin/exchange/static/img/emoji.png" width="18px" height="18px" style="margin-top: 7px;">
                        </a>
                    </div>
                    <div style="width: 30px;height: 30px;float: left;margin-left: 20px">
                        <a href="javascript:" id="emotion" title="插入表情">
                            <img src="../addons/ewei_shopv2/plugin/exchange/static/img/qq.png" width="18px" height="18px" style="margin-top: 7px;">
                        </a>
                    </div>
                    <div style="width: 30px;height: 30px;float: left;margin-left: 20px">
                        <a href="javascript:" id="link" title="插入链接">
                            <img src="../addons/ewei_shopv2/plugin/exchange/static/img/link.png" width="18px" height="18px" style="margin-top: 7px;">
                        </a>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label"></label>
            <div class="col-sm-9 col-xs-12">
                <input type="submit" value="保存" class="btn btn-primary">
            </div>
        </div>
</div>

        <div id="yulan" {if $setting['reply_type'] == 1}style="display: none;"{/if}>
            <div class="tab-pane" id="balance">
                <div class="col-sm-4">
                    <div class="chatPanel form" style="width:300px;">
                        <div style="text-align: left; padding-bottom: 10px; display: block;">
                            <div class="btn" style="margin-right: 4px;max-width: 300px;text-align:left;width: 300px;height: 360px;border: 1px solid #cdcdcd;border-radius: 5px;">
                                <span class="title" style="line-height: 1.2em;margin-top: 10px;display: block;max-width: 312px;text-align: left;"><h3 style="color: #000;height: 17px" id="t">商品兑换</h3></span>
                                <span class="time">{php echo date('m月d日',time());}</span>
                                <div class="mediaImg" style="margin-top: 6px;width: 275px;height: 170px">
                                    <img id="balancepic" src="" width="100%" height="100%">
                                </div>
                                <div style="word-break: keep-all">
                                    <p id="balanceinfo">欢迎来到兑换中心，您的兑换码是：OE3ER13789JHOA0Q</p>
                                    <style>
                                        #svinfo, #balanceinfo {
                                            margin-top: 15px;
                                            clear: both; /* 清除左右浮动 */
                                            width: 100%; /* 必须定义宽度 */
                                            height: 40px;
                                            word-break: break-word; /* 文本行的任意字内断开 */
                                            word-wrap: break-word; /* IE */
                                            white-space: -moz-pre-wrap; /* Mozilla */
                                            white-space: -hp-pre-wrap; /* HP printers */
                                            white-space: -o-pre-wrap; /* Opera 7 */
                                            white-space: -pre-wrap; /* Opera 4-6 */
                                            white-space: pre; /* CSS2 */
                                            white-space: pre-wrap; /* CSS 2.1 */
                                            white-space: pre-line; /* CSS 3 (and 2.1 as well, actually) */
                                        }
                                    </style>
                                </div>
                                <div style="color: #000;">查看全文</div>
                            </div>
                            <div style="clear:both;"></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-7" style="margin-left: 30px">
                {if $setting['code_type'] == 3}
                <div class="form-group">
                    <label class="col-sm-3 control-label">触发关键字</label>
                    <div class="col-sm-9">
                        <input type="text" name="keyword" class="form-control" value="{$setting['reply_keyword']}">
                        <br>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-sm-3 control-label">消息标题</label>
                    <div class="col-sm-9">
                        <input type="text" name="balancetitle" id="balancetitle" class="form-control" value="{$setting['title_reply']}">
                        <br>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-3 control-label">消息图片</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image(balanceimg,$setting['img']);}
                        <br>
                    </div>
                </div>
                <script type="text/javascript">
                    $(document).ready(
                            $("#yulan").on('mouseover', function () {
                                var c = $('#balancecontent').val();
                                $("#balanceinfo").html(c);
                                var g = $(".img-responsive").attr('src');
                                $('#balancepic').attr('src', g);
                                var t = $("#balancetitle").val();
                                $('#t').html(t);
                            })
                    );
                    $(document).ready(
                            $("#yulan").on('keyup', function () {
                                var c = $('#balancecontent').val();
                                $("#balanceinfo").html(c);
                                var g = $(".img-responsive").attr('src');
                                $('#balancepic').attr('src', g);
                                var t = $("#balancetitle").val();
                                $('#t').html(t);
                            })
                    );
                    $(document).ready(function () {

                        var c = $('#balancecontent').val();
                        $("#balanceinfo").html(c);
                        var g = $(".img-responsive").attr('src');
                        $('#balancepic').attr('src', g);
                        var t = $("#balancetitle").val();
                        $('#t').html(t);
                    });
                </script>
                <div class="form-group">
                    <label class="col-sm-3 control-label">消息内容</label>
                    <div class="col-sm-9 col-xs-12">
                        <textarea name="balancecontent" id="balancecontent" cols="30" rows="10" class="form-control" style="height: 6rem" id="balancecontent" maxlength="30">{$setting['content']}</textarea>
                    </div>
                </div>
                {if $setting['code_type'] == 3}
                <div class="form-group">
                    <label class="col-sm-3 control-label">开启回复</label>
                    <div class="col-sm-9">
                        <label class="radio-inline"><input type="radio" value="1" name="replystatus" {if $setting['reply_status'] != 0}checked{/if}> 开启</label>
                        <label class="radio-inline"><input type="radio" value="0" name="replystatus" {if $setting['reply_status'] == 0}checked{/if}> 关闭</label>
                    </div>
                </div>
                {/if}
                <div class="form-group">
                    <label class="col-sm-3 control-label"></label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="submit" value="保存" class="btn btn-primary">
                    </div>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="tab-pane fade" id="zhuangxiu">
    <form action="{php echo webUrl('exchange/goods/banner',array('id'=>$id));}" method="post" class="form-horizontal form-validate" novalidate="novalidate">
        {if p('diypage')}
            <div class="form-group">
                <label class="col-sm-2 control-label">自定义模板</label>
                <div class="col-sm-9 col-xs-12">
                    <select class="form-control valid" name="diypage" aria-invalid="false">
                        <option value="">请选择商品详情页自定义模板</option>
                        {loop $exchangePages $exchangePage}
                        <option value="{$exchangePage['id']}" {if $setting['diypage']==$exchangePage['id']}selected="selected"{/if}>{$exchangePage['name']}</option>
                        {/loop}
                    </select>
                </div>
            </div>
        {/if}
        <div class="form-group">
            <label class="col-sm-2 control-label">兑换幻灯片展示</label>
            <div class="col-sm-9 col-xs-12">
                {php echo tpl_form_field_multi_image('banner', $banner);}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">兑换规则设置</label>
            <div class="col-sm-9 col-xs-12">
                {php echo tpl_ueditor('rule', $setting['rule']);}
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label"></label>
            <div class="col-sm-9 col-xs-12">
                <input type="submit" value="保存" class="btn btn-primary">
            </div>
        </div>
    </form>
</div>
</div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var keyword = $('#keyword').val();
        var base = '{php echo webUrl("exchange/goods/selector",array("id"=>$id),1);}';
        var url = base + '&keyword='+keyword;
        htmlobj = $.ajax({url:url,async:false});
        $(".tableso").html(htmlobj.responseText);
        $('#so').click(function () {
            var keyword = $('#keyword').val();
            var base = '{php echo webUrl("exchange/goods/selector",array("id"=>$id),1);}';
            var url = base + '&keyword='+keyword;
            htmlobj = $.ajax({url:url,async:false});
            $(".tableso").html(htmlobj.responseText);
        });
    });



    $(document).ready(function () {
        if ($('#select_goods').is(':checked')){
            $('#goods-group').show();
        }
        if ($('#select_balance').is(':checked')){
            $('#balance-group').show;
        }
        if ($('#select_red').is(':checked')){
            $('#red-group').show;
        }
        if ($('#select_score').is(':checked')){
            $('#score-group').show;
        }
        if ($('#select_coupon').is(':checked')){
            $('#coupon-group').show;
        }
    });

    $(document).ready(function () {
        $('#select_goods').click(function () {
            if ($('#select_goods').is(':checked')){
                $('#goods-group').show(250);
            }else {
                $('#goods-group').hide(250);
            }
        });
        $('#select_balance').click(function () {
            if ($('#select_balance').is(':checked')){
                $('#balance-group').show(250);
            }else {
                $('#balance-group').hide(250);
            }
        });
        $('#select_red').click(function () {
            if ($('#select_red').is(':checked')){
                $('#red-group').show(250);
            }else {
                $('#red-group').hide(250);
            }
        });
        $('#select_score').click(function () {
            if ($('#select_score').is(':checked')){
                $('#score-group').show(250);
            }else {
                $('#score-group').hide(250);
            }
        });
        $('#select_coupon').click(function () {
            if ($('#select_coupon').is(':checked')){
                $('#coupon-group').show(250);
            }else {
                $('#coupon-group').hide(250);
            }
        });
    });
</script>
{template '_footer'}